package fsu.cs.cis5930;


import java.util.List;
import java.util.Scanner;

import android.graphics.drawable.Drawable;
import android.location.Location;
import android.os.Bundle;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;



public class GMapsActivity extends MapActivity {
    /** Called when the activity is first created. */
    
	private MapView mapView;
	GeoPoint points;
	GeoPoint target;
	private GlobalApplication GLOBAL;
	
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map_location);
       
        mapView = (MapView) findViewById(R.id.map_view);
        mapView.setBuiltInZoomControls(true);  
        GLOBAL = (GlobalApplication) getApplicationContext();
 
        
        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable = this.getResources().getDrawable(R.drawable.blue_dot);
        HelloItemizedOverlay itemizedOverlay = new HelloItemizedOverlay(drawable, this);
     
        
       String location  = GLOBAL.getMyLocation();
       Scanner scanner = new Scanner(location);
       scanner.useDelimiter(":");
       
       int lat = Integer.parseInt(scanner.next().trim());
       int lon = Integer.parseInt(scanner.next().trim());
      	target = new GeoPoint(lat, lon);
        
        
      
       
       
        	OverlayItem overlayitem = new OverlayItem(target, null, null);
        	
        		
        		itemizedOverlay.addOverlay(overlayitem);
        	 
        	mapOverlays.add(itemizedOverlay);
        
        MapController mapController = mapView.getController();
        
        mapController.animateTo(target);
        mapController.setZoom(17);
        mapView.invalidate();
        
        
        
        
	}

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}
	
	
	
	
}
